%% This file writes data from AMPL

% parameters: the structure of data
% output_file: the name of the data file from AMPL

% Get AMPL output. Initialize variables.
temp.filename = output_file; temp.delimiter = ',';

% Format string for each line of text: column1: text (%s) column2: double (%f)
% For more information, see the TEXTSCAN documentation.
temp.formatSpec = '%s%f%[^\n\r]';

% Open the text file.
temp.fileID = fopen(temp.filename,'r');

% Read columns of data according to format string.
temp.dataArray = textscan(temp.fileID, temp.formatSpec, 'Delimiter', temp.delimiter,  'ReturnOnError', false);

% Close the text file.
fclose(temp.fileID);
% 
% Create output variable
temp.dataArray(2) = cellfun(@(x) num2cell(x), temp.dataArray(2), 'UniformOutput', false);
parameters = [temp.dataArray{1:end-1}];